.TH std::pair 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::pair \- std::pair

.SH Synopsis
   Defined in header <utility>
   template<

       class T1,
       class T2

   > struct pair;

   std::pair is a class template that provides a way to store two heterogeneous objects
   as a single unit. A pair is a specific case of a std::tuple with two elements.

   If neither T1 nor T2 is a possibly cv-qualified class type with non-trivial
   destructor, or array thereof, the destructor of pair is trivial.

.SH Template parameters

   T1, T2 - the types of the elements that the pair stores.

.SH Member types

   Member type Definition
   first_type  T1
   second_type T2

.SH Member objects

   Member name Type
   first       T1
   second      T2

.SH Member functions

   constructor   constructs new pair
                 \fI(public member function)\fP
   operator=     assigns the contents
                 \fI(public member function)\fP
   swap          swaps the contents
   \fI(C++11)\fP       \fI(public member function)\fP

.SH Non-member functions

   make_pair            creates a pair object of type, defined by the argument types
                        \fI(function template)\fP
   operator==
   operator!=
   operator<
   operator<=
   operator>
   operator>=           lexicographically compares the values in the pair
   operator<=>          \fI(function template)\fP
   (removed in C++20)
   (removed in C++20)
   (removed in C++20)
   (removed in C++20)
   (removed in C++20)
   (C++20)
   std::swap(std::pair) specializes the std::swap algorithm
   \fI(C++11)\fP              \fI(function template)\fP
   get(std::pair)       accesses an element of a pair
   \fI(C++11)\fP              \fI(function template)\fP

.SH Helper classes

   std::tuple_size<std::pair>             obtains the size of a pair
   \fI(C++11)\fP                                \fI(class template specialization)\fP
   std::tuple_element<std::pair>          obtains the type of the elements of pair
   \fI(C++11)\fP                                \fI(class template specialization)\fP
   std::basic_common_reference<std::pair> determines the common reference type of two
   (C++23)                                pairs
                                          \fI(class template specialization)\fP
   std::common_type<std::pair>            determines the common type of two pairs
   (C++23)                                \fI(class template specialization)\fP
   std::formatter<std::pair>              formatting support for pair
   (C++23)                                \fI(class template specialization)\fP

   Deduction guides\fI(since C++17)\fP

   Defect reports

   The following behavior-changing defect reports were applied retroactively to
   previously published C++ standards.

      DR    Applied to              Behavior as published              Correct behavior
   LWG 2796 C++98      triviality of the destructor of pair was        specified
                       unspecified

.SH See also

   tuple   implements fixed size container, which holds elements of possibly different
   \fI(C++11)\fP types
           \fI(class template)\fP
   tie     creates a tuple of lvalue references or unpacks a tuple into individual
   \fI(C++11)\fP objects
           \fI(function template)\fP
